package com.dhcc.sds.ws.dhcmessage;

import com.alibaba.fastjson.JSONObject;

import javax.xml.rpc.ServiceException;
import java.rmi.RemoteException;

public class Test {

	public static void main(String[] args) {
		DHCMessageServiceLocator dhcLocator = new DHCMessageServiceLocator();

		String context = "该出院患者是单病种入组患者，请及时填写病种上报信息。";					//消息提醒的信息
		String actionTypeCode = "1288";				//信息的动作类型代码  websys.DHCMessageActionType表的code字段值 回龙观1140
		String fromUserRowId = "^单病种系统";		//信息发出人	SS_User->SSUSR_rowid, 如果消息发出人不在his人员表中,可直接传用户姓名。格式:"^Name"
		String episodeId = "4284";					//病人就诊Id	 		PA_Adm->PAADM_RowId
		String ordItemId = null;					//医嘱明细表Id			OE_OrdItem->OEORI_RowId  无为Null
		String toUserRowId = null;				//信息发给人			SS_User->SSUSR_rowid  强制把消息发给该用户

		String linkUrl = "dhc.sds.formFilling.message.csp?EpisodeID="+episodeId+"&mrListId=1471734879661166593";
		JSONObject job = new JSONObject();  //封装访问vte评估页面的连接以及参数
		job.put("link", linkUrl);
		job.put("dialogWidth", "1400px");
		job.put("dialogHeight", "900px");
		job.put("messageCode", actionTypeCode);

		String otherInfoJson = job.toString();	//其它业务相关对象    Json格式,一些其它信息,如link等{"link":"x.csp?type=a&id=1"}
		String locId = null;						//接收消息科室ID 可以为null
		String effectiveDays = null;				//有效时间  为null 长久有效？
		String createLoc = null;				//创建消息的科室？
		String backCode = "";					//消息返回值 消息ID >0表示成功
		try {
			DHCMessageServiceSoap soap = dhcLocator.getDHCMessageServiceSoap("http://10.1.20.24:57772/","imedical/web");
			backCode = soap.send(
					context,
					actionTypeCode,
					fromUserRowId,
					episodeId,
					ordItemId,
					toUserRowId,
					otherInfoJson,
					locId,
					effectiveDays,
					createLoc);

		} catch (ServiceException e) {
			e.printStackTrace();
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("消息返回值(消息ID)："+backCode);
	}

}
